//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: PersistentRights.cs
//
//  Description: Rights applied on persistent objects.
// 
//--------------------------------------------------------------------------

using System;

namespace Chili.Opf3
{
	/// <summary>
	/// The member of this enumeration mark a persistent object with certain rights.
	/// </summary>
	/// <remarks>
	/// This enumeration is used to mark persistent objects with certain rights. It 
	/// allows to specify the rights of the persistent object. Some persistent objects may 
	/// only be loaded and have no right to be saved or deleted from the storage. If the 
	/// persistent object is marked with the Insert right it can't be loaded, deleted or updated.
	/// The enumeration contains an All flag which is the combination of all rights.
	/// </remarks>
	/// <example>
	///     The following example shows an example persistent that is only allowed to be loaded.
	///     <code lang="CS">
	/// [Persistent("USER", Rights = PersistentRights.Load)]
	/// public class User
	/// {
	///     private string _name;
	///     
	///     [Field("NAME")]
	///     public string Name
	///     {
	///         get { return _name; }
	///         set { _name = value; }
	///     }
	///     
	///     // ... Other properties and fields.
	/// }
	///     </code>
	/// </example>
	[Serializable]
	[Flags]
	public enum PersistentRights
	{
		/// <summary>
		/// No right is granted to the persistent object. I can't be loaded, inserted, updated or deleted.
		/// </summary>
		None = 0,
		/// <summary>
		/// The persistent object is only allowed to be loaded.
		/// </summary>
		Load = 1,
		/// <summary>
		/// The persistent object is only allowed to be inserted.
		/// </summary>
		Insert = 2,
		/// <summary>
		/// The persistent object is only allowed to be updated.
		/// </summary>
		Update = 4,
		/// <summary>
		/// The persistent object is only allowed to be deleted.
		/// </summary>
		Delete = 8,
		/// <summary>
		/// The persistent object has all rights.
		/// </summary>
		All = 15
	}
}
